package com.kou.controller;/**
 * @author SteinY
 * @create 2022-03-28 10:23
 * @description:
 */

import com.kou.service.TypeService;
import com.kou.service.impl.TypeServiceImpl;
import com.kou.utils.StrUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * projectName:myshop2
 * author:SteinY
 * time:2022/3/28 10:23
 * description:
 */
@WebServlet("/addGoodsType")
public class AddGoodsType extends HttpServlet {
    TypeService typeService = new TypeServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String goodsParent = request.getParameter("goodsParent");
        String typename = request.getParameter("typename");
        if (!StrUtils.empty(typename))
        {
            request.setAttribute("msg","类型名称不能为空！");
            request.getRequestDispatcher("message.jsp").forward(request,response);
        }
        typeService.create(goodsParent,typename);
        request.getRequestDispatcher("admin/showGoodsType.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}